<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="format-detection" content="telephone=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>采买任务</title>
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <script type="text/javascript" src="../js/set_root.js"></script>
    <link rel="stylesheet" type="text/css" href="css/buyTaskList20190718.css">
    <link rel="stylesheet" type="text/css" href="../css/reset.css" />
    <link rel="stylesheet" type="text/css" href="/js/cube-ui/cube.min.css" />
    <link rel="stylesheet" type="text/css" href="/js/mint-ui/mint-ui.css" />
    <!--纠错分享样式 -->
    <link rel="stylesheet" type="text/css" href="/priceCcorrection/css/shareAndCorrection20190718.css">
</head>

<body>
    <div id="buyTaskList" class="buy-main" v-cloak>
        <div class="buyTaskList-main buy-main">
            <div class="buyTaskList-headerBox">
                <div class="buyTaskList-header">
                    <img src="../image/member_fanhui.png" />
                    <span v-if="showType === 0"><a href="/myTask/myTask.html">返回</a></span>
                    <span v-else="showType !== 0" @click="goBack">返回</a></span>
                    <h2>{{headerTitle}}</h2>
                    <span v-if="showType === 0" class="buyTaskList-headerRigth" @click="showType = 2,currentPage = 1 ,getHistoryData(0) ">历史</span>
                    <span v-if="showType === 2" class="buyTaskList-headerRigth" @click="historyScreen">筛选</span>
                </div>
                <div class="buyTaskList-store" v-show="showType != 1">
                    <span class="buyTaskList-storeIcon">{{market.marketName}}</span>
                    <div class="buyTaskList-storeLine"></div>
                    <span class="buyTaskList-changeStore" @click="changeMarket">修改超市</span>
                </div>
                <div class="buyTaskList-selectBox" v-show="showType === 0">
                    <div class="buyTaskList-select" v-for="(item,index) in orderTitle" @click="changeOrderType(index)">
                        <span class="buyTaskList-select" :class="orderType == index ? 'buyTaskList-selectTitle' :''">
                            {{item.type}}
                        </span>
                    </div>
                </div>
                <div class="buyTaskList-tabLine"></div>
            </div>

            <div :class="orderType != 1 ? 'buyTaskDetail-m':'buyTaskDetail-div'" v-show="showType != 1">
                <div v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="4">
                    <div class="buyTaskDetail-main" v-for="(item,index) in listData">
                        <div class="buyTaskDetail-numbering">{{orderType === 0 ? "需完成时间：" : "订单编号："}}{{orderType === 0 ? item.dueTime?(new Date(item.dueTime).Format("yy-MM-dd hh:mm")):'':item.taskNo}}<span class="buyTaskDetail-date">{{orderType === 1 && item.createTime.length!= undefined? item.createTime : ''}}</span></div>
                        <div class="shareAndCorrection-infoBox" v-if="orderType != 1">
                            <label for="">
                                    <input v-if="orderType === 0"
                                        @change="changeOne($event,item.procureMergeTasksId)" type="checkbox"
                                        :checked="checkModel.indexOf(item.procureMergeTasksId)>-1" class="shareAndCorrection-checkBox">
                                </label>
                            <img :src="item.supermarketLogo" alt="" class="buyTaskDetail-image">
                            <div class="buyTaskDetail-infoBoxRight">
                                <p :class="orderType ===0 ? 'buyTaskDetail-finishedName':'buyTaskDetail-finishedName-active'">超市名称：{{item.supermarketName}}</p>
                                <div class="buyTaskDetail-infoNum">
                                    <div class="buyTaskDetail-infoDiv" v-if="orderType === 2">
                                        <div class="buyTaskDetail-completeQuantity">{{"订单总金额："+item.totalPrice/100}}</div>
                                    </div>
                                    <div class="buyTaskDetail-infoDiv" v-if="orderType ===0"></div>
                                    <div class="buyTaskDetail-errorBtn-div" v-if="orderType === 0">
                                        <button class="buyTaskDetail-error"></button>
                                        <button class="buyTaskDetail-errorBtn" @click="postTaskId(item.procureMergeTasksId)">抢单</button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="buyTaskDetail-Boxinfo" v-if="orderType !== 0" v-for="(items,key) in item.procureTaskItems">
                            <label for="">
                                    <input v-if="orderType === 1"
                                        @change="changeModel($event,items,index,key)" type="checkbox"
                                        :checked="conductCheckModel.indexOf(items.procureTaskItemId)>-1" class="shareAndCorrection-checkBox">
                                </label>
                            <img :src="items.goodsSkuImage" alt="" class="buyTaskDetail-image">
                            <div class="buyTaskDetail-infoBoxRight">
                                <p class="buyTaskDetail-finishedName">商品名称：{{items.goodsSkuName}}</p>
                                <p class="buyTaskDetail-completeQuantity">条形码：{{items.barcode}}</p>
                                <div class="buyTaskDetail-infoNum">
                                    <div class="buyTaskDetail-infoDiv">
                                        <div class="buyTaskDetail-completeQuantity">采买数量：{{items.taskQuantity}}件</div>
                                        <div class="buyTaskDetail-completeQuantity">单价：{{items.taskPrice?items.taskPrice/100+"元":"暂无价格"}}</div>
                                        <div class="buyTaskDetail-completeQuantity">合计金额：{{(items.taskQuantity*items.taskPrice)/100}}元</div>
                                    </div>
                                    <div class="buyTaskDetail-errorBtn-div" v-if="orderType === 1">
                                        <button  :class="items.disabled === false? 'buyTaskDetail-errorBtn':'buyTaskDetail-errorBtnDisabled'" @click="priceCorrection(items,index,key)">价格纠错</button>
                                        <button class="buyTaskDetail-errorBtn" @click="showPopup(items)">已买{{items.actQuantity?"（"+items.actQuantity+"）":''}}</button> </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- tips -->
            <div class="toast-container" v-if="errMsg">
                <div class="toast"><span v-html="errMsg"></span></div>
            </div>

            <!-- 全选 TODO -->
            <div class="buyTaskDetail-selectAll" v-show="orderType !== 2">
                <label class="buyTaskDetail-change-btn" v-if="orderType === 0"><input type="checkbox" @click="changeAllState" v-model.trim="checkedAll" class="shareAndCorrection-checkBox">{{(checkModel.length === 0 && conductCheckModel.length === 0)?"  全选":conductCheckModel.length === 0 ?(" 已选  "+checkModel.length):("  已选  "+conductCheckModel.length)}}</label>
                <span class="buyTaskDetail-btn" @click="checkModel.length>0 && postTaskId(null)||conductCheckModel.length>0 && postTaskId(null)" v-if="orderType !== 2">{{orderType === 0 ? "抢单" : "完成"}}</span>
            </div>

            <!-- 输入采买数量  TODO-->
            <div class="buyTaskDetail-layer" v-show="outOfStock_popup && orderType === 1">
                <div class="buyTaskDetail-layerbg"></div>
                <div class="buyTaskDetail-container" @click="hidePriceShareBox($event)">
                    <div class="buyTaskDetail-other" v-show="otherMarket">
                        <div v-if="!promptOutOfStock" class="buyTaskDetail-popupTitle">请输入采买数量</div>
                        <div v-if="promptOutOfStock" class="buyTaskDetail-text">提示</div>
                        <div v-if="promptOutOfStock" style="text-align: center;color: #666666;font-size: .32rem;line-height: .8rem;">您有未采买商品,请确认是否缺货</div>
                        <input v-if="!promptOutOfStock" class="buyTaskDetail-input" v-model.trim="quantity" type="text" placeholder="" />
                        <div :class="!promptOutOfStock?'buyTaskDetail-sureTopLine': 'buyTaskDetail-sure'">
                            <span v-if="!promptOutOfStock" style="color:#EC7E2D" @click="purchasedQuantity()">确定</span>
                            <span v-if="promptOutOfStock" class="buyTaskDetail-cancel" @click="closePopup()">取消</span>
                            <span v-if="promptOutOfStock" class="buyTaskDetail-submit" @click="closePopup()">确定</span>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 纠错 -->
            <div class="shareAndCorrection-priceCorrection buyTaskDetail-boxTop" v-if="showType === 1">
                <div class="buyTaskDetail-main">
                    <!-- <div class="shareAndCorrection-numbering">任务编号：{{listData[sequence.index].procureTaskItems?(listData[sequence.index].procureTaskItems[sequence.key].procureTaskItemId):''}}
                            <span class="shareAndCorrection-date">{{listData[sequence.index].createTime}}</span>
                        </div> -->
                    <div class="shareAndCorrection-infoBox">
                        <img :src="listData[sequence.index].procureTaskItems[sequence.key].goodsSkuImage" alt="" class="shareAndCorrection-image">
                        <div class="shareAndCorrection-infoBoxRight">
                            <p class="shareAndCorrection-finishedName">{{listData[sequence.index].procureTaskItems?(listData[sequence.index].procureTaskItems[sequence.key].goodsSkuName):''}}</p>
                            <div class="shareAndCorrection-infoNum">
                                <span class="shareAndCorrection-noPrice">{{listData[sequence.index].procureTaskItems[sequence.key].taskPrice?"￥"+listData[sequence.index].procureTaskItems[sequence.key].taskPrice/100+'元':''}}<span class="buyTaskDetail-barcode">{{'条形码：'+listData[sequence.index].procureTaskItems[sequence.key].barcode}}</span></span>
                                <div class="shareAndCorrection-completeQuantity">提成金额：￥{{listData[sequence.index].royaltyAmount?listData[sequence.index].royaltyAmount/100:''}}元</div>
                            </div>
                        </div>
                    </div>
                </div>
                <div>
                    <ul>
                        <li class="shareAndCorrection-correctionListLi"><span class="shareAndCorrection-correctionListLiLeft">价格类型：</span>
                            <div class="shareAndCorrection-correctionListLiRight" @click="choicePriceType">{{params.priceType}}</div>
                        </li>
                        <li class="shareAndCorrection-correctionListLi"><span class="shareAndCorrection-correctionListLiLeft">开始时间：</span>
                            <div class="shareAndCorrection-correctionListLiRight" @click="choiceStartAndEndTime">{{params.startTime}}</div>
                        </li>
                        <li class="shareAndCorrection-correctionListLi"><span class="shareAndCorrection-correctionListLiLeft">结束时间：</span>
                            <div class="shareAndCorrection-correctionListLiRight" @click="choiceStartAndEndTime">{{params.endTime}}</div>
                        </li>
                        <li class="shareAndCorrection-correctionListLi"><span class="shareAndCorrection-correctionListLiLeft">纠错价格：</span><input type="number" class="shareAndCorrection-correctionListLiRight" v-model="params.price" placeholder="请输入价格（元）"></li>
                    </ul>
                </div>
                <div class="buyTaskDetail-submitDiv">
                    <button class="buyTaskDetail-btnSubmit" :primary="true" :disabled="btnDisabled" @click="shareAndCorrectionSubmit">完成</button>
                </div>
            </div>

        </div>

        <!-- 历史 -->
        <div class="buyTaskDetail-historyContainer" v-if="showType === 2">
            <div class="shareAndCorrection-historyDiv">
                <button :class="historyStatus === 0 ?'shareAndCorrection-history-btnActive':'shareAndCorrection-history-btn'" @click="getHistoryData(0)">采买任务</button>
                <button :class="historyStatus === 1 ?'shareAndCorrection-history-btnActive':'shareAndCorrection-history-btn'" @click="getHistoryData(1)">纠错任务</button>
            </div>
            <cube-scroll ref="historyData" :data="historyData" :options="scrollOptions" @pulling-up="historyDataMore">
                <ul class="shareAndCorrection-auditListHistoryBox" v-if="historyData && historyData.length > 0">
                    <li class="shareAndCorrection-auditListHistory" v-for="(history, index) in historyData" :key="index">
                        <div class="shareAndCorrection-auditListHeader" v-if="historyStatus === 0">
                            <span>完成时间：{{format(history.dueTime)}}</span>
                            <span class="shareAndCorrection-auditListStatus" v-if="history.dealStatus">{{history.status === 'IN_PROGRESS'?'采买中':'采买完成'}}</span>
                        </div>
                        <div class="shareAndCorrection-auditListHeader" v-if="historyStatus === 1">
                            <span></span>
                            <span class="shareAndCorrection-auditListStatus" style="color: #ff1d1d;">纠错任务：{{
                                    history.status === 'WAIT_AUDIT'||history.status==='AUDIT_SUCCESS'?'失败':history.status==='RECALL'||history.status==='AUDIT_FAIL'?'失败':'完成'}}</span>
                        </div>
                        <div class="shareAndCorrection-auditGoodsBox">
                            <img :src="history.supermarketLogo||history.goodsImage" class="shareAndCorrection-auditGoodsImg">
                            <div class="shareAndCorrection-auditGoodsInfo">
                                <h1 :class="historyStatus === 0?'buyTaskDetail-auditGoodsName':'shareAndCorrection-auditGoodsName'">{{history.supermarketName?'超市名称：'+history.supermarketName:history.fullName}}</h1>
                                <h1 class="buyTaskDetail-auditGoodsName" v-if="historyStatus === 0">任务编号：{{history.taskNo}}</h1>
                                <div class="shareAndCorrection-priceBox" v-if="historyStatus === 1">
                                    <p><span>价格：{{"￥"+history.price/100||"暂无价格"}}</span><span class="buyTaskDetail-spanRight">条形码：{{history.barcode}}</span></p>
                                    <p>提成金额："￥"{{history.royaltyAmount/100}}</p>
                                </div>
                                <!-- <button class="shareAndCorrection-historyBtn"  v-if="history.historyButtonType === 'RECALL'" @click="revokePrice(index)">撤销价格</button>
                                <button class="shareAndCorrection-historyBtn" v-else-if="history.historyButtonType === 'VIEW'" @click="viewPrice(index)">查看价格</button>
                                <button class="shareAndCorrection-historyBtn" v-else-if="history.historyButtonType === 'CORRECT'" @click="errorCorrection(index)">价格纠错</button> -->
                            </div>
                        </div>
                    </li>
                </ul>
                <div class="shareAndCorrection-noHistory" v-else-if="historyData && historyData.length === 0">暂无历史</div>
            </cube-scroll>
        </div>

        <!-- 选择超市 -->
        <cube-popup type="my-popup" position="right" :mask-closable="true" ref="choiceMarket">
            <div class="shareAndCorrection-choiceMarketBox">
                <div class="shareAndCorrection-choiceMarketTitle">选择超市</div>
                <div class="shareAndCorrection-choiceMarketInputBox">
                    <input type="text" class="shareAndCorrection-choiceMarketInput" v-model="marketKey" placeholder="请输入超市名">
                </div>
                <div class="shareAndCorrection-marketListBox">
                    <cube-scroll ref="marketData" :data="marketData" :options="scrollOptions" @pulling-up="marketDataMore">
                        <ul v-if="marketData ">
                            <li class="shareAndCorrection-marketList" v-for="(item,index) in marketData" :key="index" @click="choiceMarket(item)">
                                <h1 class="shareAndCorrection-marketName" v-html="item.name"></h1>
                                <p class="shareAndCorrection-marketAddress">{{item.fullName}}</p>
                            </li>
                        </ul>
                        <div class="shareAndCorrection-noMarket" v-else-if="marketData ">暂无结果</div>
                    </cube-scroll>
                </div>
            </div>
        </cube-popup>

    </div>
    </div>
    <script type="text/javascript" src="../js/vue.js"></script>
    <script src="../js/layout.js" type="text/javascript" charset="utf-8"></script>
    <!--<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>-->
    <script type="text/javascript" src="../js/axios.min.js"></script>
    <script type="text/javascript" src="/js/fetch20190612.js"></script>
    <script src="../js/cube-ui/cube.min.js"></script>
    <script type="text/javascript" src="/js/mint-ui/mint-ui.js"></script>
    <script src="js/buyTaskList20190718.js" type="text/javascript" charset="utf-8"></script>
</body>

</html>